import { get, post, put, del } from '@/utils/request';
import type { ApiResponse } from '@/types/api';
import type { SysMenu } from '@/types/system';

export function menuList() {
  return get<ApiResponse<SysMenu[]>>('/sysMenu/list');
}

export function menuGet(menuId: number) {
  return get<ApiResponse<SysMenu>>(`/sysMenu/${menuId}`);
}

export function menuAdd(body: SysMenu) {
  return post<ApiResponse<string>>('/sysMenu/add', body);
}

export function menuUpdate(body: SysMenu) {
  return put<ApiResponse<string>>('/sysMenu/update', body);
}

export function menuDelete(menuIdList: number[]) {
  const params = new URLSearchParams();
  params.set('menuIdList', menuIdList.join(','));
  return del<ApiResponse<string>>(`/sysMenu/delete?${params.toString()}`);
}